package com.AFH.test;
import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class WelcomeViewDrawThread extends Thread{
	WelcomeView wv;
	SurfaceHolder surfaceHolder;
	boolean DrawOn;
	boolean flag=false;
	int sleeptime = 50;
	int startMonsterId=0;
	
	WelcomeViewDrawThread(WelcomeView wv,SurfaceHolder surfaceHolder){
		super.setName("WelcomeViewDrawThread");
		this.wv= wv;
		this.surfaceHolder=surfaceHolder;
		DrawOn= true;
		flag=true;
		
	}
	
	@Override
	public void run(){
		while(flag){
			
			Canvas canvas = null;
			while(DrawOn){
				if(wv.alpha<255) wv.alpha+=5;
				if(wv.framemove<40)wv.framemove++;
				try{
					
					canvas = surfaceHolder.lockCanvas(null);
					synchronized(surfaceHolder){
						wv.doDraw(canvas);
//						if(wv.isTouch==1){
//						//	surfaceHolder.unlockCanvasAndPost(canvas);
//							int selected = wv.selectedIndex;
//							wv.vs.AfhHandler.sendEmptyMessage(selected);
//						}
//						wv.isTouch= -1;
					}				
				}
				catch(Exception e){
					e.printStackTrace();
				}
				finally{//閿熼叺鏀句紮鎷烽敓鏂ゆ嫹
					if(canvas != null){
						surfaceHolder.unlockCanvasAndPost(canvas);
					}
				}
				try{
					Thread.sleep(sleeptime);
				}
				catch(Exception e){
					e.printStackTrace();
				}
			}
			try{//閿熸枻鎷烽敓绐栴叏鎷烽敓鍓款垽鎷烽敓锟�				Thread.sleep(2000);
			}
			catch(Exception e){
				e.printStackTrace();
			}
		}
	}
}
	
